package models

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	OrderNo string  `gorm:"type:varchar(20);unique;not null;comment:'订单账号'"`
	Totam   float64 `gorm:"type:decimal(10,2);not null;comment:'总价'"`
	Pay     string  `gorm:"type:int;not null;comment:' 支付方式 1 支付宝 2 微信'"`
	Xiadan  string  `gorm:"type:varchar(20);not null;comment:'下单'"`
	Peisong string  `gorm:"type:varchar(20);not null;comment:'配送'"`
	Finish  string  `gorm:"type:varchar(20);not nul;;comment:'完成'"`
	Jiedan  string  `gorm:"type:varchar(20);not null; comment:'接单'"`
	UserId  int     `gorm:"type:int;not null; comment:'用户id'"`
}
type OrderPinglun struct {
	gorm.Model
	Context    string  `gorm:"type:varchar(255);not null;comment:评价内容'"`
	Start      float64 `gorm:"decimal(10,2);not null;comment:'星级评分'"`
	Image      string  `gorm:"type:varchar(255);not null;comment:图片上传'"`
	Shoppeople string  `gorm:"type:varchar(255);not null;comment:商家评价'"`
	Qishou     string  `gorm:"type:varchar(255);not null;comment:骑手评价'"`
	Status     int     `gorm:"type:int;not null;comment:'0 审核未通过 1 审核通过'"`
}

type Peisong struct {
	gorm.Model
	OrderNo string `gorm:"type:varchar(20);unique;not null;comment:'订单账号'"`
	Qishou  string `gorm:"varchar(20);not null;comment:'骑手'"`
	Address string `gorm:"varchar(20);not null;comment:'骑手距离商家'"`
	Status  int    `gorm:"type:int;not null;comment:'0 未送到 1 已送到'"`
}

func (o *Order) GetOrderShow(ordersId int) error {
	return DB.Debug().Where(ordersId).Limit(1).Find(&o).Error
}

func (o *Order) CreateOrder() error {
	return DB.Debug().Create(&o).Error
}

func (p *OrderPinglun) CreateOrderPinglun() error {
	return DB.Debug().Create(&p).Error
}

func (p *Peisong) CreatePeisong() error {
	return DB.Debug().Create(&p).Error
}
